0) { $ret = 'You did not Select the Datafile, Browse and Select it before clicking Register Items' ; //echo "Error: " . $_FILES["images"]["error"] ; } else { //define variables $cat = trim($_POST['cat']) ; //$names = trim($_POST['file']) ; $file = $_FILES['file']['tmp_name']; $handle = fopen($file, "r"); $c = 0; $bcd = 'nill' ; $cpp = 0 ; while(($filesop = fgetcsv($handle, 1000, ",")) !== false) { $names = $filesop[0]; $price = $filesop[1]; //chk if the result has been uploaded before $chksql = $DBcon->prepare("select * from items where (item_category =:ct and item_name= :na)") ; $chksql->bindparam(":ct",$cat) ; $chksql->bindparam(":na",$names) ; $chksql->execute() ; //$crow = mysql_fetch_array($rac); if($chksql->rowcount() > 0) $dupl = "$names - has been Uploaded Before, Select another data File" ; else { $sql = $DBcon->prepare("insert into items (item_category,item_name,barcode,cprice,bar_price,vlprice,staff) values (:ct,:na,:bc,:cp,:bp,:vp,:st)"); $sql->bindparam(":ct",$cat) ; $sql->bindparam(":na",$names) ; $sql->bindparam(":bc",$bcd) ; $sql->bindparam(":cp",$cpp) ; $sql->bindparam(":bp",$price) ; $sql->bindparam(":vp",$price) ; $sql->bindparam(":st",$adm) ; if($sql->execute()) $ok = 'yes' ; else $ok = 'no'; $c = $c + 1; } } if($ok = 'yes'){ //echo "You database has imported successfully. You have inserted ". $c ." recoreds"; $message[] = " Uploaded Succesfully ". $c ." recoreds"; }else{ $message [] = "Sorry! There is some problem."; } } } ?>